package org.jeecg.modules.report.controller;




import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;

import org.jeecg.modules.param.member.entity.BikeMemberUser;
import org.jeecg.modules.param.member.vo.MemberStatisticsReq;
import org.jeecg.modules.param.member.vo.MemberStatisticsRsp;
import org.jeecg.modules.report.entity.BusinessReport;
import org.jeecg.modules.report.service.ReportService;
import org.jeecg.modules.report.vo.BusinessReportReq;
import org.jeecg.modules.utils.ExcelUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 月月鸟
 *  数据分析
 */
@Api(tags="数据分析")
@RestController
@RequestMapping("/report/report")
@Slf4j
public class ReportController {
    @Autowired
    private ReportService reportService;

    /**
     * 营业统计报表
     * @param businessReportReq
     * @param req
     * @return
     */
    @ApiOperation(value="数据分析-营业统计报表", notes="数据分析-营业统计报表")
    @GetMapping(value = "/businessReport")
    public Result<?> businessReport(BusinessReportReq businessReportReq,
                                    HttpServletRequest req) {
        List<BusinessReport> businessReports = reportService.businessReportList(businessReportReq,req);
        return Result.OK(businessReports);
    }

    /**
     数据分析-营业统计报表 导出
     * @return
     */
    @ApiOperation(value="数据分析-营业统计报表-导出", notes="数据分析-营业统计报表-导出")
    @GetMapping(value = "/exportXlsStatistics")
    public ModelAndView exportXlsStatistics(BusinessReportReq businessReportReq,
                                            HttpServletRequest req) {

        List<BusinessReport> businessReports = reportService.businessReportList(businessReportReq,req);
        return ExcelUtils.exportXls(req,businessReports,BusinessReport.class,"营业统计报表");
    }
}
